import asyncio
from bleak import BleakScanner

async def find_bluetooth_devices():
    print("正在搜索已连接的蓝牙设备...")
    devices = await BleakScanner.discover(timeout=5.0)

    if not devices:
        print("未找到任何蓝牙设备。")
        return

    print("找到以下蓝牙设备：")
    for device in devices:
        # print(device)
        print(f"设备名称: {device.name}, 设备地址: {device.address}")
    return devices

# 主函数
def main():
    devices = asyncio.run(find_bluetooth_devices())
    print(devices)

if __name__ == "__main__":
    main()